package top.csjss.hospital.controller;


import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.csjss.hospital.entity.SysUser;
import top.csjss.hospital.service.SysUserService;
import top.csjss.hospital.vo.SideVO;

import java.util.List;


/**
 * @Author ztf
 * @Date 22:11 2021/10/15
 **/
@RestController
public class SideController {
    private Logger log = LoggerFactory.getLogger(SideController.class);

    @Autowired
    private SysUserService sysUserService;

    @GetMapping("/side")
    public List<SideVO> side() {
        //获取当前用户的id
        Subject subject = SecurityUtils.getSubject();
        SysUser sysUser = (SysUser) subject.getPrincipal();
        if (subject == null){
            log.info("当前用户登录超时");
            return null;
        }
        //调用service查询数据
        List<SideVO> result = sysUserService.findMenuByUserId(sysUser.getUserId());
        return result;
    }
}
